<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据查看</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
</head>
<%@include file="../include/header.jsp" %>
<body>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <form class="layui-form" action="${ctx}/crowdfund/project/copartnerCrowList.do?targetId=${projectWithAuthor.targetId}&relationId=${projectWithAuthor.relationId}" id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">众筹状态</label>
                                <div class="check-btn-inner">
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),'','#myForm')" ${empty projectWithAuthor.isSuccess ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${projectWithAuthor.isSuccess == 0 ? 'class="active"' : ''}>众筹中</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${projectWithAuthor.isSuccess == 1 ? 'class="active"' : ''}>众筹成功</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${projectWithAuthor.isSuccess == 3 ? 'class="active"' : ''}>退款中</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),4,'#myForm')" ${projectWithAuthor.isSuccess == 4 ? 'class="active"' : ''}>退款成功</a>
                                    <input type="hidden" name="isSuccess" value="${projectWithAuthor.isSuccess}"/>
                                </div>
                            </li>
                            <li class="form-item">
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable" style="text-indent: 13px;">众筹者</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="authorName" autocomplete="off" class="layui-input" value="${projectWithAuthor.authorName}" placeholder="众筹者">
                                </div>
                            </li>
                            <li class="form-item-inline"><label class="search-form-lable">联系电话</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="authorMobile" autocomplete="off" class="layui-input" value="${projectWithAuthor.authorMobile}" placeholder="联系电话">
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <label class="search-form-lable">排序方式</label>
                                <div class="layui-input-inline">
                                    <select name="sort">
                                        <option value="0" ${projectWithAuthor.sort == 0 ? 'selected="selected"' : ''}>金额最多</option>
                                        <option value="1" ${projectWithAuthor.sort == 1 ? 'selected="selected"' : ''}>时间最近</option>
                                    </select>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">筛选金额</label>
                                <div class="layui-input-inline">
                                    <select name="operator">
                                        <option value="0" <c:if test="${projectWithAuthor.operator == 0}">selected</c:if>>等于</option>
                                        <option value="1" <c:if test="${projectWithAuthor.operator == 1}">selected</c:if>>小于</option>
                                        <option value="2" <c:if test="${projectWithAuthor.operator == 2}">selected</c:if>>大于</option>
                                    </select>
                                </div>
                                <div class="layui-input-inline">
                                    <input type="text" name="operatorNum" autocomplete="off" class="layui-input" value="${projectWithAuthor.operatorNum}" placeholder="金额">
                                </div>
                            </li>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>
            <form class="layui-form" action="${ctx}/crowdfund/project/listForDistributorIdExport.do" id="exportForm" method="post">
                <input type="hidden" name="relationId" value="${relationId}">
                <input type="hidden" name="name" value="${name}">
            </form>
            <div class="my-act-list-content">
                <ul class="num">
                    <div class="l">
                        <li class="f16">众筹人数<span class="red">${page.totalCount}</span>人</li>
                        <li class="f16">总金额
                            <span class="red">
                                <c:if test="${totalMoney > 0}">
                                    <fmt:formatNumber pattern="#,###.##" value="${totalMoney}"/>
                                </c:if>
                                <c:if test="${totalMoney == 0.0}">
                                    ${totalMoney}
                                </c:if>
                            </span> 元
                        </li>
                        <li class="f16">退款金额
                            <span class="red">
                                <c:if test="${refundMoney > 0}">
                                    <fmt:formatNumber pattern="#,###.##" value="${refundMoney}"/>
                                </c:if>
                                <c:if test="${refundMoney == 0.0}">
                                    ${refundMoney}
                                </c:if>
                            </span> 元
                        </li>
                        <li class="f16">剩余金额
                            <span class="red">
                                <c:if test="${remainMoney > 0}">
                                    <fmt:formatNumber pattern="#,###.##" value="${remainMoney}"/>
                                </c:if>
                                <c:if test="${remainMoney == 0.0}">
                                    ${remainMoney}
                                </c:if>
                            </span> 元
                        </li>
                        <li class="f16">累计佣金
                            <span class="red">
                                <c:if test="${totalBrokerage > 0}">
                                    <fmt:formatNumber pattern="#,###.##" value="${totalBrokerage}"/>
                                </c:if>
                                <c:if test="${totalBrokerage == 0.0}">
                                    ${totalBrokerage}
                                </c:if>
                            </span> 元
                        </li>
                    </div>
                    <%--<div class="l" style="width: 10%">
                        <li style="cursor: pointer;" class="r">
                            <a class="layui-btn layui-btn-danger layui-btn-sm" id="btnExport">导出EXCEL</a>
                        </li>
                    </div>--%>
                    <p class="cl"></p>
                </ul>
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                            <col>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>众筹者</th>
                            <th>渠道</th>
                            <th>公司</th>
                            <th>区域</th>
                            <th>职务</th>
                            <th>联系电话</th>
                            <th>支持人数</th>
                            <th>支持金额</th>
                            <th>真实金额</th>
                            <th>浏览量</th>
                            <th>众筹状态</th>
                            <th>转移状态</th>
                            <th>直接佣金收入</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach var="directPay" items="${list}">
                            <tr>
                                <td class="table-member"
                                    onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${directPay.authorId}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img">
                                            <img src="<c:if test="${directPay.authorLogo != null}">${directPay.authorLogo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                 alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1">
                                            <a class="blue" title="${directPay.authorName}" href="javascript:void(0);">${directPay.authorName}</a>
                                        </div>
                                    </div>
                                </td>
                                <td>${name}</td>
                                <td>
                                    <div class="ellipsis-1" title="${directPay.authorCompany}">${directPay.authorCompany}</div>
                                </td>
                                <td>${directPay.cityName}</td>
                                <td>${directPay.authorJobTitle}</td>
                                <td>${directPay.authorMobile}</td>
                                <td>${directPay.favorerNum}</td>
                                <td>${directPay.actualAmount}</td>
                                <td>${empty directPay.realTimeAmount ? '0.0' : directPay.realTimeAmount}</td>
                                <td>${directPay.viewNum}</td>
                                <td>
                                    <c:if test="${directPay.isSuccess == 0}">
                                        <span>众筹中</span>
                                    </c:if>
                                    <c:if test="${directPay.isSuccess == 1}">
                                        <span>众筹成功</span>
                                    </c:if>
                                    <c:if test="${directPay.isSuccess == 2}">
                                        <span>众筹失败</span>
                                    </c:if>
                                    <c:if test="${directPay.isSuccess == 3}">
                                        <span>退款中</span>
                                    </c:if>
                                    <c:if test="${directPay.isSuccess == 4}">
                                        <span>退款成功</span>
                                    </c:if>
                                </td>
                                <td>
                                    <c:choose>
                                        <c:when test="${directPay.transferStatus == 0 ||directPay.transferStatus == null }">
                                            <span>未转移</span>
                                        </c:when>
                                        <c:when test="${directPay.transferStatus > 0}">
                                            <a href="javascript:getTargetProjectName('${directPay.id}')">
                                                        <span>
                                                        <c:choose>
                                                            <c:when test="${directPay.transferStatus == 1}">
                                                                待授权
                                                            </c:when>
                                                            <c:when test="${directPay.transferStatus == 2}">
                                                                转移成功
                                                            </c:when>
                                                            <c:when test="${directPay.transferStatus == 3}">
                                                                待审核
                                                            </c:when>
                                                            <c:when test="${directPay.transferStatus == 4}">
                                                                审核通过
                                                            </c:when>
                                                            <c:when test="${directPay.transferStatus == 5}">
                                                                审核拒绝
                                                            </c:when>
                                                        </c:choose>
                                                            </span>
                                            </a>
                                        </c:when>
                                    </c:choose>
                                </td>
                                <td>${directPay.brokerage}</td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div id="page_content" class="page-container"></div>
        </div>
        <%@include file="../include/footer.jsp" %>
    </section>
</div>


<div id="targetProjectDiv">
    <table class="layui-table" lay-skin="line">
        <tbody>
        <tr>
            <td class="table-member">
                <div class="member-cell">
                    <li>
                        <ul class="member-name ellipsis-1">

                        </ul>
                    </li>
                </div>
            </td>
        </tr>
        </tbody>
    </table>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript">

    txz.initHeader({
        nav: [{
            name: '合伙人数据分析',
            href: '${ctx}/copartner/analyze/list.do',
        }, {
            name: '${name}'
        }, {
            name: '${title}'
        },{
            name: '众筹列表',
            curr: true
        }],
        info: '<span class="f12">共<b>${page.totalCount}</b>条记录',
        btns: [{
            name: '返回',
            icon: 'back',
            href: '${ctx}/copartner/analyze/crowdfundDistributeList.do?parentId=${parentId}'
        }]
    });

    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        $("#btnExport").click(function () {
            layer.confirm('确认要导出Excel吗?', {
                icon: 3,
                title: '系统提示'
            }, function (index) {
                var url = $("#exportForm").attr("action");
                var loadIndex = layer.load(1, {
                    shade: [0.1, '#fff'] //0.1透明度的白色背景
                });
                $.post(url, $("#exportForm").serialize(), function (res) {
                    top.layer.close(loadIndex);
                    if (res.success) {
                        window.location.href = res.data;
                    } else {
                        util.layerMsgError(res.description)
                    }
                });
                top.layer.close(index);
            });
        });
    })

    function getTargetProjectName(sourceId) {
        var setPayIndex = layer.open({
            type: 1,
            area: '450px',
            title: '查看目标项目',
            content: $("#targetProjectDiv"),
            btn: ['关闭'],
            success: function () { // 弹出后回调
                $.post('${ctx}/crowdfund/project/getTargetProject.do', {
                    sourceId: sourceId
                }, function (res) {
                    if (res.success) {
                        var projectName = res.data.projectName;
                        $("#targetProjectDiv").find(".member-name").text(projectName);
                    } else {
                        util.layerMsgError(res.description)
                    }
                })
            },
            end: function () { // 销毁后回调
                $("#targetProjectDiv").find(".member-name").text('');
            },
            yes: function () { // 确定按钮
                layer.close(setPayIndex);
            }
        });
    }

</script>
</body>
</html>
